home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Oct 89 / Z0136-Re MPW C++-Oct89 < prev    next >
Encoding:
Text File  |  1989-10-20  |  2.4 KB  |  58 lines  |  [TEXT/GEOL]

  1. Item    3175905                         19-Oct-89        11:58
  2.  
  3. From:   ROSENSTEIN1                     Rosenstein, Larry
  4.  
  5. To:     D4280                           IDS, Robert Pappas, AST
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    re MPW C++
  10.  
  11. Bob,
  12.  
  13. Regarding your questions:
  14.  
  15. (1) CFront converts the symbols in your program into mangled names that encode
  16. more type and scoping information.  Mangled names always (I think) begin with 2
  17. underscores and a capital letter.  The warning you saw referred to the fact
  18. that MacApp uses a couple of symbols that also begin this way, so there may be
  19. a compilation problem.
  20.  
  21. (2) CFront will give a warning if you declare a parameter that isn't used.  You
  22. can eliminate the warning by eliminating the parameter name.  For example: void
  23. Foo(int parm1, short) could be use if the second parameter is never referenced.
  24.  
  25. (3) The message about TBirdView::Draw hiding TView::Draw does not refer to
  26. overridden methods.  It may indicate an error in writing the override, however.
  27.  
  28. In full C++, it is possible to overload a method: you can have multiple
  29. versions of a routine that take different parameters.
  30.  
  31. This applies to methods as well.  Suppose class TFoo defines a virtual method
  32. Bar.  One version takes a single int, and another takes an int and a short.
  33. (IE, TFoo::Bar(int) and TFoo::Bar(int, short).)  This is perfectly legal in
  34. C++, and the compiler will call the appropriate method based on the parameters.
  35.  
  36. One rule in C++ is that if you override one version of a virtual method, you
  37. must override all versions.  If you don't you will get the <X> hides <Y>
  38. warning.
  39.  
  40. In the example, if TSubFoo overrides Bar(int) but not Bar(int, short), then you
  41. will get the warning.
  42.  
  43. The warning also can indicate that you made a mistake when overriding a method.
  44. Suppose TSubFoo defines Bar(int) as above and Bar(int, int).  The latter method
  45. is different from the inherited method (TFoo::Bar(int, short)) and is
  46. considered a new overloaded method.  Since you still haven't overridden
  47. TFoo::Bar(int,short) you will get the message.
  48.  
  49. You have to be careful with overloading.  C++ does not require that you mark a
  50. method overidden.  If you do mis-type the parameter list you will be
  51. overloading a routine, which is perfectly legal.  You won't dicover the mistake
  52. unless you happen to get a warning, or until you look at what happens at
  53. runtime.
  54.  
  55.  
  56. Larry
  57.  
  58.